package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ReceiveInfo;
import com.ruoyi.system.service.IReceiveInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 接收信息Controller
 * 
 * @author chenming
 * @date 2024-10-16
 */
@RestController
@RequestMapping("/system/receiveInfo")
public class ReceiveInfoController extends BaseController
{
    @Autowired
    private IReceiveInfoService receiveInfoService;

    /**
     * 查询接收信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:receiveInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReceiveInfo receiveInfo)
    {
        startPage();
        List<ReceiveInfo> list = receiveInfoService.selectReceiveInfoList(receiveInfo);
        return getDataTable(list);
    }

    /**
     * 导出接收信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:receiveInfo:export')")
    @Log(title = "接收信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReceiveInfo receiveInfo)
    {
        List<ReceiveInfo> list = receiveInfoService.selectReceiveInfoList(receiveInfo);
        ExcelUtil<ReceiveInfo> util = new ExcelUtil<ReceiveInfo>(ReceiveInfo.class);
        util.exportExcel(response, list, "接收信息数据");
    }

    /**
     * 获取接收信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:receiveInfo:query')")
    @GetMapping(value = "/{receiveId}")
    public AjaxResult getInfo(@PathVariable("receiveId") Long receiveId)
    {
        return success(receiveInfoService.selectReceiveInfoByReceiveId(receiveId));
    }

    /**
     * 新增接收信息
     */
    @PreAuthorize("@ss.hasPermi('system:receiveInfo:add')")
    @Log(title = "接收信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReceiveInfo receiveInfo)
    {
        return toAjax(receiveInfoService.insertReceiveInfo(receiveInfo));
    }

    /**
     * 修改接收信息
     */
    @PreAuthorize("@ss.hasPermi('system:receiveInfo:edit')")
    @Log(title = "接收信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReceiveInfo receiveInfo)
    {
        return toAjax(receiveInfoService.updateReceiveInfo(receiveInfo));
    }

    /**
     * 删除接收信息
     */
    @PreAuthorize("@ss.hasPermi('system:receiveInfo:remove')")
    @Log(title = "接收信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{receiveIds}")
    public AjaxResult remove(@PathVariable Long[] receiveIds)
    {
        return toAjax(receiveInfoService.deleteReceiveInfoByReceiveIds(receiveIds));
    }
}
